def file_append(input_file,output_file,sep='\t',appchar='0'):
    """
    功能：追加一列-全appchar;
    调用：
    input_file = 'data/stat.txt'
    output_file = 'data/mod_stat.txt'
    file_append(input_file,output_file)

    """
    header = ''
    matrix = []

    # Parse and store all existing lines
    with open(input_file, 'r') as fin:

        # The header - remove the newline character only
        header = next(fin).strip()

        # The data - parse and store each line as a list
        # of strings, store as a sublist of matrix
        for line in fin:
            matrix.append(line.strip().split())

    # Update the header - now a newline is needed
    #header += '\t0\n'
    header += sep+appchar+'\n'

    # Now perform your calculations for each row
    # and add new column - adding 0.0 as in the comment
    for row in matrix:

        # Calculations would go here

        # This zero is already a string, normally a
        # conversion would be needed
        row.append(appchar)


    # Write it to the new file
    with open(output_file, 'w') as fout:

        # First the updated header
        fout.write(header)

        for row in matrix:
            # Turn the entries into a single string
            fout.write(sep.join(row) + '\n')


input_file = 'data/stat.txt'
output_file = 'data/stat.txt'
file_append(input_file,output_file)